package com.at.bigdata.spark.core.test

import java.io.ObjectOutputStream
import java.net.Socket

/**
 *
 * @author cdhuangchao3
 * @date 2023/3/18 10:26 AM
 */
object Driver {

  def aa(): Unit = {
    val client = new Socket("localhost", 9999)

    val out = client.getOutputStream
    val objectOutput = new ObjectOutputStream(out)

    val task = new Task()

    objectOutput.writeObject(task)
    objectOutput.flush()
    objectOutput.close()
    out.close()

    client.close()
  }

  def cc(port: Int, subTask: SubTask): Unit = {
    val client = new Socket("localhost", port)

    val out = client.getOutputStream
    val objectOutput = new ObjectOutputStream(out)

    objectOutput.writeObject(subTask)
    objectOutput.flush()
    objectOutput.close()
    out.close()

    client.close()
  }

  def bb(): Unit = {

    val task = new Task()

    val subTask = new SubTask()
    //    subTask.logic = task.logic
    subTask.datas = task.datas.take(2)

    val subTask2 = new SubTask()
    //    subTask.logic = task.logic
    subTask2.datas = task.datas.takeRight(2)

    cc(9999, subTask)
    cc(8888, subTask2)
    println("发送完毕")
  }

  def main(args: Array[String]): Unit = {
//    aa()
    bb()
  }
}
